Notepad Using Python Tkinter 您所在的位置:网站首页 tkinter pack side Notepad Using Python Tkinter

Notepad Using Python Tkinter

#Notepad Using Python Tkinter| 来源: 网络整理| 查看: 265

Introduction:

tkinter is a GUI library provided by Python to create GUI applications. In this project, with the help of this library, we are going to build up the notepad, a text editor. The notepad will have two main menu items: File & edit. The functionalities of these menu items will also be there.

Explanation:

First of all, we will import the tkinter library. With this, we will also import the “filedailog” module from tkinter which will provide the classes and factory functions for creating file selection windows.

Now, we will initiate a class named “Notepad ” by using the “class” keyword. During this process, we will pass the parameter as “tk. Tk” which will create the root object for our GUI application. Under this, we will define a “__init__” constructor with self,*args,**kwargs as parameters.

Under this constructor, we will define the title by using “.title” and create a Text widget with the help of the “.Text()” method and will make this widget fill the entire frame with the “.pack()” method.

For the notepad to show the menu bar we will create the menu widget with the help of “.Menu()”.

The functionalities provided by the File menu in this project will be: New, Open, save and exit.

and the functionalities provided by the edit menu will be: cut, copy, and paste

The following options will be created by using the “.add_cascade()” method. This method will create a new hierarchical menu by associating the given menu with the parent menu. While doing so, we will pass the user-defined functions which will carry the particular functionality, under the “command” parameter. By this, both main menu items will get created.



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

      专题文章
        CopyRight 2018-2019 实验室设备网 版权所有